package com.design.patterns.list.builder;

import com.design.patterns.list.builder.up.*;

/**
 * @author Wangzhiwen
 */
public class Client {

    /**
     * 普通的实现方式：1.抽象出产品
     *              2.客户端直接实例化，调用建造方法
     */
    private static void common(){

        AbsHouse house = new CommonHouse();
        house.build();

        AbsHouse house2 = new VillaHouse();
        house2.build();

    }

    public static void builder(){
        // 拿到构建者
        HouseBuilder commonHouseBuilder = new CommonHouseBuilder();
        // 指挥者
        HouseDirector houseDirector = new HouseDirector(commonHouseBuilder);
        // 指定流程创建产品
        House commonHouse = houseDirector.constructorHouse();
        System.out.println(commonHouse);

        // 替换构建者，构建出另外实现方式的产品
        houseDirector.setHouseBuilder(new VillaHouseBuilder());
        House villaHouse = houseDirector.constructorHouse();
        System.out.println(villaHouse);
    }

    public static void main(String[] args) {
        common();

        System.out.println("---------------------");

        builder();
    }

}
